﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using RicciWebsite.Model;
using Hxj.Data;
using Hxj.Common;

namespace RicciWebsite
{
    public partial class newslist : RicciWebsite.Pages.PageBase
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            int pageIndex = ConvertHelper.ToInt32(Request.QueryString["pg"], 1);

            FromSection<data_news> from = RicciDatabase.Default.From<data_news>().OrderBy(data_news._.status.Desc && data_news._.subtime.Desc);

            pager.RecordCount = from.Count();

            rptnewslist.DataSource = from.Page(pager.PageSize, pageIndex).ToList();
            rptnewslist.DataBind();


            RicciWebsite.masterpage._default m = this.Master.Master as RicciWebsite.masterpage._default;
            m.TabIndex = 3;
        }

        /// <summary>
        /// 返回置顶图片
        /// </summary>
        /// <param name="status"></param>
        /// <returns></returns>
        protected string getImg(object status)
        {
            if (null == status || !status.ToString().Equals(Common.NewsStatus.置顶.GetHashCode().ToString()))
                return string.Empty;

            return string.Concat("<img src='", ResolveUrl("~/images/up.gif"), "' class='articletop' alt='top' />");
        }
    }
}
